/**
 * @param {number[][]} matrix
 * @param {number} target
 * @return {boolean}
 */
var findNumberIn2DArray = function (matrix, target) {
	//  判空
	if (!matrix.length) {
		return false;
	}
	// 右上角
	let row = 0, col = matrix[0].length - 1;
	while (row <= matrix.length - 1 && col >= 0) {
		if (matrix[row][col] === target) {
			return true;
		} else if (matrix[row][col] > target) {
			// 剔除该列
			col--;
		} else {
			// 剔除该行
			row++;
		}
	}
	// 没有找到，返回假
	return false;
};

let matrix = [
  [1,   4,  7, 11, 15],
  [2,   5,  8, 12, 19],
  [3,   6,  9, 16, 22],
  [10, 13, 14, 17, 24],
  [18, 21, 23, 26, 30]
]
console.log(findNumberIn2DArray([], 20))